<%@ Page Language="C#" EnableViewState="false" ValidateRequest="false" AutoEventWireup="true" Inherits="Syrinx.Gui.AspNet.Ajax.NitobiBasePage" 
	MasterPageFile="~/App_ThemeMasters/NoStyle/AdminOneColumnLayout.Master" %>

<%@ Register Assembly="Swaf.Gui.AspNet2" Namespace="Swaf.Gui.AspNet2" TagPrefix="swf" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet.Ajax" TagPrefix="saj" %><%@ Register Assembly="NitobiControls" Namespace="Nitobi" TagPrefix="ntb" %>

<!--#include file="~/SiteControls/RegisterStandardControls.txt"-->
<!--#include file="../SiteControls/StandardAdminHeaderPageContent.inc"-->
<!--#include file="../SiteControls/StandardFooterPageContent.inc"-->

<script runat="server">
	public string TitleFormat = "$company.name$ - Sales Order Management";
</script>

<asp:Content ContentPlaceHolderID="title" runat="server" ID="c1">
	<%SecurityPrivilege = "AppFunctions.ManageProducts"; %>
	<h1 runat="server" ID="currencyConvertLbl" >Sales Order Management</h1>
	<div class="HelpBtnArea" style="float:right">
		<asp:HyperLink runat="server" ID="_pageHelp" NavigateUrl="../std/Help.aspx?helpid=SalesOrderManagementHelp" Target="help">Help</asp:HyperLink>
	</div>
	<swf:BizProc ID="som" runat="server" factoryName="eComSalesOrderMngt">
		<ParentBizProc id="loginBP" />
	</swf:BizProc>
		<swf:BizProc ID="orderItemBP" runat="server" FactoryName="eComSalesOrderItems">
		<State  entireTree="false"  EditModeSessionKey="GlobalEdit" baseListFieldNameforMaster="product" masterDataDisplay="blOnly"/>
		<ParentBizProc id="som" fieldName="id" dataId="pid" />
	</swf:BizProc>
    <swf:BizProc ID="contactBP" runat="server" FactoryName="contactBizProc" >
		<ParentBizProc id="som" fieldName="orderContact.id" dataId="id" />
	</swf:BizProc>
	
	<script type="text/javascript">
	function toggleTabs(cId,c1, dId){
		for(i=1; ;i++){
			var a = document.getElementById(cId + i);
			var b = document.getElementById(dId + i);
			if(a==null || a=='')
				break;
				
			if(i==c1){
				a.className = 'currenttab';
				b.style.display = 'block';
			}
			else{
				a.className='';
				b.style.display = 'none';
			}
		}
	}
	</script>
</asp:Content>

<asp:Content ContentPlaceHolderID="mainContent" runat="server" ID="c3">
	<div style="clear:both">
    <saj:Grid ID="salesOrderGrid" runat="server" Width="750px" Height="200px"  
        ShowToolbar="false" ParentBizProcIds="som" mode="LiveScrolling" SelectionMode="Single" Resizable="Both">
        <Columns>
            <ntb:KeyColumn DataField="id" />
            <ntb:DateColumn DataField="createdDate" HeaderText="Date" width="150" />
            <ntb:BoundColumn DataField="seqNumber" HeaderText="Order #" width="125" />
            <ntb:BoundColumn DataField="customer.userName" HeaderText="User Name" width="100" />
            <ntb:BoundColumn DataField="orderContact.fullName" HeaderText="Order Contact" width="175" />
            <ntb:BoundColumn DataField="status.title" HeaderText="Status" width="100" />
        </Columns>
    </saj:Grid>
    </div>
		<div class="tabs">
			<ul>
				<li id="t1" class="currenttab"><div class="firstTab"><swf:DivLayers runat="server" ID="tl1" SkinID="Tab"><asp:HyperLink onclick="toggleTabs('t','1','ta');" runat="server" ID="_cmpMngrTab1" Text="Order Details" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
				<li id="t2"><swf:DivLayers runat="server" ID="tl2" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','2','ta');" ID="_pubInfLbl" Text="Payment Info" NavigateUrl="javascript:;" /></swf:DivLayers></li>
				<li id="t3"><div class="lastTab"><swf:DivLayers runat="server" ID="tl3" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','3','ta');" ID="_cmpMngrTab3" Text="Shipping Info" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
			</ul>
		</div>
	<swf:DivLayers ID="mdl1" runat="server" SkinID="MainTabArea">
		<div id="ta1">
			<table cellpadding="5"><tr><td>
				<h2><asp:Label runat="server" ID="_sodtlbl">Sales Order Details</asp:Label></h2>
				<saj:NitobiBizObjDisplay ID="soDet" runat="server" 
					ReadOnlyTemplate="eCom.Gui.AspNet.SalesOrderDisplay"
					ParentBizProcIds="som" />
			<div  >
				<span class="button1"><saj:ActionButton runat="server" ID="ActionButton3" Actions="som.AddBizObj" Text="Add" /></span>
				<span class="button6"><saj:ActionButton runat="server" ID="ActionButton4" Actions="som.UpdateBizObj,contactBP.UpdateBizObj" Text="Update" /></span>
				<span class="button1"><saj:ActionButton runat="server" ID="ActionButton5" Actions="som.CancelEdits" Text="Cancel" /></span>
				<span class="button5"><saj:ActionButton runat="server" ID="ActionButton6" Actions="som.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
				<saj:NitobiBizObjDisplay ID="sog1" runat="server" 
					ReadOnlyTemplate="eCom.Gui.AspNet.SalesOrderGoPrintDisplay"
					ParentBizProcIds="som" />
			</div>
			</td><td rowspan="2">
				<div style="height:10px"></div>
				<h3><asp:Label runat="server" ID="_cntdtlbl">Contact Information</asp:Label></h3>
				<saj:NitobiBizObjDisplay ID="contactDisplay" runat="server" 
					TemplateNameBizRule="getContactAddressTemplate"
					ParentBizProcIds="contactBP" />
			</td></tr>
			<tr><td>
				<h3><asp:Label runat="server" ID="_slsItmlbl">Sales Order Items</asp:Label></h3>
				<saj:Grid ID="soi" runat="server" Width="465px" Height="150px"  
					ShowToolbar="false" ParentBizProcIds="orderItemBP" mode="LiveScrolling" SelectionMode="Single">
					<Columns>
						<ntb:KeyColumn DataField="id" visible="false" />
						<ntb:BoundColumn DataField="product.title" HeaderText="Product" width="200" />
						<ntb:BoundColumn DataField="quantity" HeaderText="Quantity" width="50" />
						<ntb:BoundColumn DataField="price.CmpCur" HeaderText="Price" width="100" />
						<ntb:BoundColumn DataField="totalFormated" HeaderText="Total" width="100" />
					</Columns>
				</saj:Grid>
			</td></tr></table>		
		</div>
		<div id="ta2" style="display:none;">
			<h3><asp:Label runat="server" ID="_paymentInfoLbl">Payment Information</asp:Label></h3>
			<swf:BizProc ID="payment" runat="server" FactoryName="salesOrderPayment" >
				<ParentBizProc id="som" fullDependency="true" fieldName="paymentMethod" dataId="current" />
			</swf:BizProc>
			
			<saj:NitobiBizObjDisplay runat="server" ID="xrsd1" 
				TemplateNameBizRule="getPaymentMethodDisplayTemplate" ParentBizProcIds="payment" />
		</div>
		<div id="ta3" style="display:none;">
			<saj:NitobiBizObjDisplay ID="NitobiBizObjDisplay1" runat="server" 
				ReadOnlyTemplate="eCom.Gui.AspNet.SalesOrderDeliveryRODisplay"
				ParentBizProcIds="som" />
		</div>
	</swf:DivLayers>
</asp:Content>
